home *** CD-ROM | disk | FTP | other *** search
Text File | 1999-03-04 | 3.5 KB | 171 lines | [TEXT/ToyS] |
- -- Properties
- property kasPrefName : "Image Icons V1.0"
-
- -- Globals
- global gasInfoWind -- Info window
- global gasInfoPos -- Position of info window
- global gasDrawing -- Draw window
- global gasDrawPos
-
- global gasFoldersToDo -- The folders left to process
- global gasShown -- Number gone!
- global gasChecked -- Number checked!
-
-
- on open fsObjs
- -- Load prefs, show window
- pfLoad()
-
- -- Set up prefix
- set gasShown to 0
- set gasChecked to 0
- set gasShowWind to 0
-
- set gasInfoWind to display info titled kasPrefName ¬
- located at gasInfoPos ¬
- message "Scanning…"
-
- -- Do files
- set gasFoldersToDo to {}
-
- repeat with fsObj in fsObjs
- set myInfo to (basic info for fsObj)
-
- if (system type of myInfo is "fold") then
- DoOne(fsObj)
- set gasFoldersToDo to gasFoldersToDo & {fsObj}
- else
- DoOne(fsObj)
- end if
- end repeat
-
- -- Do folders
- repeat while gasFoldersToDo is not {}
- -- Pop one off the end
- set n to the number of items of gasFoldersToDo
- set fsObj to item n of gasFoldersToDo
-
- if (n > 1) then
- set gasFoldersToDo to items 1 through (n - 1) of gasFoldersToDo
- else
- set gasFoldersToDo to {}
- end if
-
- display info gasInfoWind ¬
- message ("Folders to go: " & n) ¬
- at line 6 ¬
- using color (15 * 32)
-
- -- Process it
- GoDeep(fsObj)
- end repeat
-
- display info gasInfoWind message "DONE!"
-
- pause for 5 with seconds timing -- Let screen wait...
-
- set gasInfoPos to screen location of ¬
- (display info gasInfoWind with disposal)
-
- pfSave() -- Save window location
- end open
-
-
- on DoOne(fsObj)
- set fInfo to (extended info for fsObj)
- set fname to (catalog name of fInfo)
-
- display info gasInfoWind ¬
- message fname ¬
- at line 2
-
- if (custom icon status of fInfo) then
- display info gasInfoWind ¬
- message ¬
- "Removing…" at line 3
- -- Get Picture / Assign Icon
- set the icon of fsObj with to its default
- else
- display info gasInfoWind ¬
- message ¬
- "No custom icon." at line 3
- end if
- end DoOne
-
-
- on GoDeep(foldObj)
- display info gasInfoWind ¬
- message "Path: " & (foldObj as string)
-
- set daddy to foldObj as string
-
- -- Do kinds that match
- display info gasInfoWind ¬
- message "Scanning files" at line 5
-
- set myItems to the entries in foldObj ¬
- whose kinds are a file
-
- repeat with myItem in myItems
- DoOne((daddy & myItem) as alias)
- end repeat
-
- -- Do folders
- display info gasInfoWind ¬
- message "Scanning subfolders" at line 5
-
- set myItems to the entries in foldObj ¬
- whose kinds are a folder
-
- repeat with myItem in myItems
- set gasFoldersToDo to gasFoldersToDo & {(daddy & myItem) as alias}
- end repeat
-
- -- Done
- display info gasInfoWind ¬
- message "…" at line 5
- end GoDeep
-
-
- on PlaceInCenter(src, dst)
- set sW to (item 3 of src) - (item 1 of src)
- set sH to (item 4 of src) - (item 2 of src)
- set dW to (item 3 of dst) - (item 1 of dst)
- set dH to (item 4 of dst) - (item 2 of dst)
-
- set r to dW / sW
- set rH to dH / sH -- ratios
-
- if (rH < r) then set r to rH
-
- -- Round to a .25 ratio if > 1
- if (r > 1) then ¬
- set r to 0.25 * (round (r * 4))
-
- -- Scale the src
- set sW to round (sW * r)
- set sH to round (sH * r)
- set mW to round ((dW - sW) / 2) + (item 1 of dst)
- set mH to round ((dH - sH) / 2) + (item 2 of dst)
-
- -- Center it
- return {mW, mH, mW + sW, mH + sH}
- end PlaceInCenter
-
-
- on pfLoad()
- try
- set ourPrefs to (load preference named kasPrefName)
- on error
- set ourPrefs to {{8, 48}, {8, 112}}
- end try
-
- set gasInfoPos to item 1 of ourPrefs
- set gasDrawPos to item 2 of ourPrefs
- end pfLoad
-
-
- on pfSave()
- save preference {gasInfoPos, gasDrawPos} named kasPrefName
- end pfSave
-